package com.extremeforce.adapter;

import java.util.ArrayList;
import java.util.HashMap;

import com.extremeforce.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SingleGoodsAdapter extends BaseAdapter{

	private ArrayList<HashMap<String,String>> list = null;
	private Context context;
	public SingleGoodsAdapter(Context context,ArrayList<HashMap<String,String>> list){
		this.context = context;
		this.list = list;
	}
	public int getCount() {
		return list.size();
	}

	public Object getItem(int arg0) {
		return null;
	}

	public long getItemId(int position) {
		return 0;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = LayoutInflater.from(context);
		convertView = inflater.inflate(R.layout.singlegoodsitem,null);
		HashMap<String,String> map = list.get(position);
		TextView goodsNameTextView = (TextView)convertView.findViewById(R.id.goodsNameTextView);
		goodsNameTextView.setText(map.get("GOODS_NAME"));
		
		TextView shopNameTextView = (TextView)convertView.findViewById(R.id.center_left);
		shopNameTextView.setText(map.get("SHOP_NAME"));
		
		
		TextView yearTextView = (TextView)convertView.findViewById(R.id.endDateTextView);
		yearTextView.setText(map.get("EXEC_TIME").split(" ")[0]);
		
		
		TextView timeTextView = (TextView)convertView.findViewById(R.id.endTimeTextView);
		timeTextView.setText(map.get("EXEC_TIME").split(" ")[1]);
		
		
		TextView salesTextView = (TextView)convertView.findViewById(R.id.discountTextView);
		
		salesTextView.setText(map.get("DISCOUNT_NUM"));
		
		return convertView;
	}

}
